package com.z.controller;

import com.alibaba.fastjson.JSON;
import com.z.pojo.Goods;
import com.z.service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;

@WebServlet("/indexGoods")
public class IndexGoodsServlet extends HttpServlet {
    private GoodsServiceImpl gs = new GoodsServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        Map<String, List<Goods>> map = gs.IndexGoods();
        String s = JSON.toJSONString(map);
        resp.getWriter().write(s);
    }
}
